<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.text.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="org.osgi.framework.*"%>
<%@ page import="com.gzgi.framework.*"%>
<%@ page import="com.gzgi.framework.util.*"%>
<%@ page import="com.gzgi.framework.context.*"%>
<%@ page import="com.gzgi.framework.config.*"%>
<%@ page import="com.gzgi.osgi.runtime.*"%>
<%@ page import="com.gzgi.osgi.modules.hibernate.*"%>
<%@ page import="com.gzgi.osgi.modules.service.*"%>
<%
        System.setProperty("aQute.fileinstall.dir", MessageProperties.getConfigRootPath()+"/load");
        OSGiRuntime runtime = OSGiRuntime.getRuntime();
        BundleContext bundleContext = runtime.getBundleContext();
        System.out.println(bundleContext);
		Properties props01 = new Properties();
		props01.put("SessionService", "sessionService");
		bundleContext.registerService(SessionServiceImpl.class.getName(), new SessionServiceImpl(), props01);
        ServiceReference[] refs01 = bundleContext.getServiceReferences(SessionServiceImpl.class.getName(), "(SessionService=*)");

		Properties props02 = new Properties();
		props02.put("EntityService", "entityService");
		bundleContext.registerService(EntityServiceImpl.class.getName(), new EntityServiceImpl(), props02);
        ServiceReference[] refs02 = bundleContext.getServiceReferences(EntityServiceImpl.class.getName(), "(EntityService=*)");
		if (refs01 != null && refs02 != null) {
			SessionServiceImpl sessionService = (SessionServiceImpl)  bundleContext.getService(refs01[0]);
			EntityServiceImpl entityService = (EntityServiceImpl)  bundleContext.getService(refs02[0]);
			System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
			System.out.println("sessionService:"+sessionService);
			System.out.println("entityService:"+entityService);
			String hsql = " select a from com.gzgi.framework.dataitem.DataItem as a where a.nodeCode = 'province' ";
			try{
				//org.hibernate.Session s = sessionService.get();
				//org.hibernate.Query query = s.createQuery(hsql);
				//List list  = query.list();
				//System.out.println("rows:"+list);
			} finally {
			      //sessionService.release();
		     }
		}
 %>